Note: There are often multiple ways to answer each question.
Load the ggplot2
, dplyr
and maps
packages and save the world map data frame into the variable map_world
. (Hint: Look at this PDF for hints on where the world map data frame is saved.)
Plot the world map, ensuring that the aspect ratio of the map is correct and that the countries have white fill and black outline.
Save the coordinates for just the region “China” in the variable map_china
. Plot with the same settings as above, except that in addition, we don’t see the latitude and longitude axes.
Load US state-level data into the variable map_state
. Plot just the states of California, Oregon and Washington.
Load the datasets
package. (The dataset
package contains variables state.name
and state.division
which we will use.) Create a data frame named division
such that the first column region
contains state.name
in lower case, and the second column division
contains state.division
.
Join division
to map_state
(with map_state
on the left) on the key region
.
Plot a map of the US at state-level, with the fill of the states indicating the division it belongs to.
Figure out why there is an NA in the legend in the map resulting from Question 7. Modify the data frame so that the NA is not included.
Augment the map from Question 7 with state abbreviations in the center of the map, using state.abb
and state.center
to help you. (Hint: Combine state.abb
and state.center
into an auxiliary data frame first.)
You may have noticed that the state abbreviations for Hawaii and Alaska were included, even though they were not drawn. (This of course depends on how you drew the map in Question 9.) Redo the map above, but without plotting the abbreviations for these two states.